package com.sdhs.system.syncdata.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author zhangmy
 * @date 2024/4/1910:42
 * @Description: 生成默认密码
 */
public class PasswordUtils {
    private static final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

    public PasswordUtils() {
    }

    public static String encode(String str) {
        return passwordEncoder.encode(str);
    }

    public static boolean matches(String str, String password) {
        return passwordEncoder.matches(str, password);
    }

    public static void main(String[] args) {
        String str = "admin";
        String password = encode(str);
        System.out.println(password);
        System.out.println(matches(str, password));
    }
}
